/* $RCSFile: ADNDynCalendar.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynCalendar.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:48  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynCalendar : DynEntity
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.calendar)
            {}

            public override Type DynType
            { get { return typeof(ADNDynCalendar); } }

            public override string DynTypename
            {   get{ return CrmStr.calendar;}}

            public override DynEntity Build()
            {   return new ADNDynCalendar();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynCalendar(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynCalendar(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynCalendar(w,PrimaryKeyValue);}
        }

        static ADNDynCalendar(){new Ftor();} 

        public override bool HasOwnerProperty
        {
            get
            {
                return false;
            }
        }

        public override bool HasBusinessUnitProperty
        {
            get
            {
                return true;
            }
        }

        public ADNDynCalendar(): base()
		{}

        public ADNDynCalendar(CRMWrapperBase w, string PrimaryFiedlValue)
			: base(w, CrmStr.calendar)
		{
            if ( PrimaryFiedlValue != string.Empty )
                name    =   PrimaryFiedlValue;
		}

		public ADNDynCalendar(CRMWrapperBase w, Guid CrmId)
			: base(w,CrmStr.calendar, CrmId)
		{}

		public ADNDynCalendar(CRMWrapperBase w, InternalDynamicEntity e)
			: base(w,CrmStr.calendar,e,null,null)
		{}

		public ADNDynCalendar(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(w,CrmStr.calendar,e,prop,s)
		{}

        public ADNDynCalendar(ResetWrapperHandler fn, string PrimaryFiedlValue)
			: base(fn, CrmStr.calendar)
		{
            if ( PrimaryFiedlValue != string.Empty )
                name    =   PrimaryFiedlValue;
		}

		public ADNDynCalendar(ResetWrapperHandler fn, Guid CrmId)
			: base(fn,CrmStr.calendar, CrmId)
		{}

		public ADNDynCalendar(ResetWrapperHandler fn, InternalDynamicEntity e)
			: base(fn,CrmStr.calendar,e,null,null)
		{}

		public ADNDynCalendar(ResetWrapperHandler fn, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(fn,CrmStr.calendar,e,prop,s)
		{}

		/// <summary>
		/// Crm Key
		/// </summary>
        [CrmDynAttribute(CrmStr.calendar)]
        public Guid calendarid
		{
			get
			{
				return KeyPropertyValue(CrmStr.calendarid);
			}
			set
			{
				AddKeyProperty(CrmStr.calendarid, value);
			}
		}

        protected override void SetCrmIdProperty(Guid crmId)
        {
           if ( !dicProperty.ContainsKey(CrmStr.calendarid) || KeyPropertyValue(CrmStr.calendarid) != crmId )
                calendarid   =   crmId;
        }
        
        public override string PrimaryFieldName
        {
            get
            {
               return CrmStr.name;
            }
           set
           {}
        }

        /// <summary>
        /// Value contained in the PrimaryField for the DynEntity or empty if no PrimaryField
        /// </summary>
        public override string PrimaryFieldStringValue
        {
            get
            {
                return name;
            }
            set
            {
                name =   value;
            }
        }

        public override Guid PrimaryKeyGuidValue
        {
           get
           {
                return calendarid;
           }
           set
           {
               calendarid    =   value;
           }
        }

        /// <summary>
        /// Gets or sets the subject of the annotation. 
        /// </summary>
        [CrmDynAttribute(CrmStr.calendar)]
        public override string name 
        {
            get
            {
                return StringPropertyValue(CrmStr.name);
            }
            set
            {
                AddStringProperty(CrmStr.name,value);
            }
        }

        public Guid primaryuserid
        {
           get
           {
                return UniqueIdentifierPropertyValue(CrmStr.primaryuserid);
           }
           set
           {
               AddUniqueIdentifierProperty(CrmStr.primaryuserid,value);
           }
        }

        /// <summary>
        /// Gets or sets the mimetype of the annotation attached file. 
        /// </summary>
        [CrmDynAttribute(CrmStr.calendar)]
        public string description 
        {
            get
            {
                return StringPropertyValue(CrmStr.description);
            }
            set
            {
                AddStringProperty(CrmStr.description,value);
            }
        }
        
        /// <summary>
        /// Gets or sets the ID of the subject associated with the knowledge base article 
        /// </summary>
        [CrmDynAttribute(CrmStr.calendar)]
        public object calendarrules
        {
            get
            {
                if (ContainsKey(CrmStr.calendarrules))
                    return CalendarRulesPropertyValue(CrmStr.calendarrules);
                return null;
            }
            set
            {
                AddCalendarRulesProperty(CrmStr.calendarrules,value);
            }
        }

        [CrmDynAttribute(CrmStr.calendar)]
        public bool isshared
        {
            get 
            {
                return BooleanPropertyValue(CrmStr.isshared);
            }
            set 
            {
                AddBooleanProperty(CrmStr.isshared,value);
            }
        }

        [CrmDynAttribute(CrmStr.calendar)]
   		public Guid businessunitid
        {
            get
            {
				return LookupPropertyValue(CrmStr.businessunitid);
            }
            set
            {
                AddLookupProperty(CrmStr.businessunitid,CrmStr.businessunit,value);
            }
        }

   		public string businessunitName
        {
            get
            {
                if ( ContainsKey(CrmStr.businessunitid) )
				    return LookupPropertyName(CrmStr.businessunitid);
                return string.Empty;
            }
        }
    }
}
